package tr.edu.ege.kipler.satisfiability.container;

import java.util.Set;

import tr.edu.ege.kipler.common.MultivalueHashMap;

/**
 * 
 * @author İnanç Seylan
 *
 */
public class ModifiedIndividualList implements ModifiedIndividualCollection {
	private MultivalueHashMap<String, String> worldIndvMap = new MultivalueHashMap<String, String>();

	/*
	 * (non-Javadoc)
	 * 
	 * @see tr.edu.ege.kipler.satisfiability.container.ModifiedIndividualCollection#add(java.lang.String,
	 *      java.lang.String)
	 */
	public void add(String w, String indvName) {
		worldIndvMap.put(w, indvName);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see tr.edu.ege.kipler.satisfiability.container.ModifiedIndividualCollection#remove(java.lang.String,
	 *      java.lang.String)
	 */
	public void remove(String w, String indv) {
		worldIndvMap.remove(w, indv);
	}

	// TODO: Write a test for it
	/*
	 * (non-Javadoc)
	 * 
	 * @see tr.edu.ege.kipler.satisfiability.container.ModifiedIndividualCollection#replace(java.lang.String,
	 *      java.lang.String, java.lang.String)
	 */
	public void replace(String w, String toBeReplaced, String replaceWith) {
		if (worldIndvMap.containsKeyValue(w, toBeReplaced)) {
			worldIndvMap.remove(w, toBeReplaced);
			worldIndvMap.put(w, replaceWith);
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see tr.edu.ege.kipler.satisfiability.container.ModifiedIndividualCollection#get(java.lang.String)
	 */
	public Set<String> get(String w) {
		return worldIndvMap.getValuesForKey(w);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see tr.edu.ege.kipler.satisfiability.container.ModifiedIndividualCollection#copy()
	 */
	public ModifiedIndividualList copy() {
		ModifiedIndividualList result = new ModifiedIndividualList();
		result.worldIndvMap = worldIndvMap.copy();
		return result;
	}

}
